﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.constant;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;
using System.Globalization;
using System.Windows.Data;

namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("OutVarName")]
    public class GetOpenedWebObjNParam:BaseParam {
        //当前激活网页0，根据标题1，根据网址2
        private BrowserType browType = BrowserType.GOOGLE;
        private int matchType = 0;
        private string matchContent;
        private string outVarName = "webPage";
        public string MatchContent {
            get => matchContent; 
            set { 
                matchContent = value;
                NotifyPropertyChanged("MatchContent");
            }  
        }

        public BrowserType BrowType {
            get => browType; 
            set {
                browType = value;
                NotifyPropertyChanged("BrowserType");
            }  
        }
        public string OutVarName {
            get => outVarName; 
            set { 
                outVarName = value;
                NotifyPropertyChanged("OutVarName");
            }  
        }
        public int MatchType {
            get => matchType; 
            set { 
                matchType = value;
                NotifyPropertyChanged("MatchType");
            }
        }
        public string GetTranslateMatchType() {
            switch(this.matchType) {
                case 0:
                    return "根据当前激活网页";
                case 1:
                    return $"根据标题:{this.matchContent}";
                case 2:
                    return $"根据网址:{this.matchContent}";
                default : return "当前激活网页";
            }
        }

        public string GetTranslateBrowType() {
            switch(this.browType) {
                case BrowserType.GOOGLE:
                    return "GOOGLE浏览器";
                case BrowserType.IE:
                    return "IE浏览器";
                case BrowserType.EDGE:
                    return "Edge浏览器";
                default : return "GOOGLE浏览器";
            }
        }

        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.outVarName = this.GetLatestName(this.outVarName, globleData);
        }
    }
}
